﻿@{
    ViewBag.Title = "网站管理平台_新建用户菜单项";
}

@(Html.X().Viewport()
    .Layout("fit")
    .Items(
        Html.X().FormPanel()
            .ID("FormPanel1")
            .Layout("fit")
            .Items(
                Html.X().Panel()
                    .Border(false)
                    .Padding(5)
                    .Layout("form")
                    .Defaults(
                        Html.X().Parameter().Name("AnchorHorizontal").Value("90%")
                    )
                    .Items(
                        Html.X().Hidden().ID("GID").Text((string)ViewBag.GID),
                        Html.X().ComboBox().ID("MenuID").FieldLabel("栏目菜单").Editable(false)
                            .EmptyText("请选择栏目菜单")
                            .Store(Html.X().Store()
                                .Model(Html.X().Model().IDProperty("MenuID")
                                    .Fields(
                                        new ModelField("MenuID", ModelFieldType.Int),
                                        new ModelField("MenuName")
                                    )
                                )
                                .Proxy(Html.X().AjaxProxy().Url(Url.Action("GetAllMenuByMtype", "Menu")).Reader(Html.X().JsonReader().Root("data")))
                            )
                            .Listeners(ls =>
                                ls.Select.Handler = "App.ItemID.clearValue(); App.ItemID.getStore().load()"
                            )
                            .ValueField("MenuID")
                            .DisplayField("MenuName"),
                        Html.X().ComboBox().ID("ItemID").FieldLabel("用户所属菜单项").AllowBlank(false).Editable(false)
                            .QueryMode(DataLoadMode.Local)
                            .ValueNotFoundText("找不到响应菜单项")
                            .Store(Html.X().Store()
                                .AutoLoad(false)
                                .Model(Html.X().Model().IDProperty("ItemID")
                                    .Fields(
                                        new ModelField("ItemID", ModelFieldType.Int),
                                        new ModelField("ItemName")
                                    )
                                )
                                .Proxy(Html.X().AjaxProxy().Url(Url.Action("GetAllMenuItemsByMenuId", "MenuItem")).Reader(Html.X().JsonReader().Root("data")))
                                .Parameters(Html.X().StoreParameter().Name("menuId").Value("App.MenuID.getValue()").Mode(ParameterMode.Raw))
                                .Listeners(ls =>
                                    ls.Load.Handler = @"var combo = App.ItemID; combo.setValue(records[0].get(combo.valueField));"
                                )
                            )
                            .ValueField("ItemID")
                            .DisplayField("ItemName"),
                        Html.X().NumberField().ID("SortNum").FieldLabel("序号").MinValue(0).Text("0")
                    )
            )
            .TopBar(
                Html.X().Toolbar().Items(
                    Html.X().Button().Text("保存").Icon(Icon.Disk)
                        .DirectEvents(de =>
                        {
                            de.Click.Action = "CreateMemMuItem";
                            de.Click.EventMask.ShowMask = true;
                            de.Click.EventMask.Msg = "正在保存";
                            de.Click.Success = "ext.net.comjs.onSubmitSuccess";
                            de.Click.Failure = "ext.net.comjs.onSubmitFailure";
                        })
                        .Listeners(ls =>
                        {
                            ls.Click.Handler = "return ext.net.comjs.onFormSubmit()";
                        })
                )
            )
            .BottomBar(Html.X().StatusBar().DefaultText("Ready"))
                .Listeners(ls => ls.ValidityChange.Handler = "ext.net.comjs.setFormStatusBar(this, valid)")
    )
)